<script setup lang="ts">
import Taro from "@tarojs/taro";
import { useRouter } from "@tarojs/taro";

import ByCell from "@/components/ui/ByCell.vue";
import Page from "@/components/common/Page.vue";
import ViewList from "@/components/common/ViewList.vue";

import useList from "@/hooks/useList";
import ApiMerchant from "@/api/merchant";

import { MerchantActivityVerifyItem } from "@/global";

const { params } = useRouter<{
  // 活动商户id
  id: `${number}`;
}>();


const id = parseInt(params.id);

// 获取商户活动销售数据列表
const { list, loading } = useList<MerchantActivityVerifyItem>(
  ApiMerchant.getMerchantActivityVerifyDateList,
  { search: { activity_apply_id: id } }
);

const handleNavigate = async ({ date }: { date: string; }) => {
  Taro.navigateTo({
    url: `/packageMerchant/pages/sale/verifyList?id=${id}&date=${date}`,
  });
};

</script>

<template>
  <Page height="200rpx" hiddenHeaderBg>
    <ViewList class="p-4" :loading="loading" :is-empty="list.length === 0">
      <ByCell
              next
              align="right"
              :label="item.date"
              class="mb-4 px-2 py-3 bg-[#BB8554]/20 rounded-lg"
              @tap="handleNavigate(item)"
              v-for="item in list"
              :key="item.date">
        <text class="text-2xl text-[#ac1717]">
          {{ item.verify_count }}
        </text>
      </ByCell>
    </ViewList>
  </Page>
</template>
